using FineCollection.Intf;

using NUnit.Framework;

namespace FineCollection.Immutable
{


    [TestFixture]
    public class ImmTinySet_test
    {

        [Test]
        public void Test_Constructor_2()
        {
            ImmTinySet<byte> s1 = new ImmTinySet<byte>(11,22);

            Assert.IsTrue(s1.IsNotEmpty);
            Assert.IsFalse(s1.IsEmpty);
            Assert.AreEqual(2, s1.Count);

            Assert.IsTrue(s1.Contains(11));
            Assert.IsTrue(s1.Contains(22));
            Assert.IsFalse(s1.Contains(0));
            Assert.IsFalse(s1.Contains(33));
        }


        [Test]
        public void Test_Constructor_3()
        {
            ImmTinySet<byte> s1 = new ImmTinySet<byte>(11,22,33);

            Assert.IsTrue(s1.IsNotEmpty);
            Assert.IsFalse(s1.IsEmpty);
            Assert.AreEqual(3, s1.Count);

            Assert.IsTrue(s1.Contains(11));
            Assert.IsTrue(s1.Contains(22));
            Assert.IsTrue(s1.Contains(33));
            Assert.IsFalse(s1.Contains(0));
            Assert.IsFalse(s1.Contains(44));
        }


        [Test]
        public void Test_Constructor_4()
        {
            ImmTinySet<byte> s1 = new ImmTinySet<byte>(11,22,33,44);

            Assert.IsTrue(s1.IsNotEmpty);
            Assert.IsFalse(s1.IsEmpty);
            Assert.AreEqual(4, s1.Count);

            Assert.IsTrue(s1.Contains(11));
            Assert.IsTrue(s1.Contains(22));
            Assert.IsTrue(s1.Contains(33));
            Assert.IsTrue(s1.Contains(44));
            Assert.IsFalse(s1.Contains(0));
            Assert.IsFalse(s1.Contains(55));
        }


        [Test]
        public void Test_Constructor_Array_0()
        {
            long[] emptyArray = new long[0];
            ImmTinySet<long> s1 = new ImmTinySet<long>(emptyArray);

            Assert.AreEqual(0, s1.Count);
            Assert.IsFalse(s1.IsNotEmpty);
            Assert.IsTrue(s1.IsEmpty);
        }


        [Test]
        public void Test_Constructor_Array_1()
        {
            long[] arr1 = new long[] {11111111};
            ImmTinySet<long> s1 = new ImmTinySet<long>(arr1);

            Assert.AreEqual(1, s1.Count);
            Assert.IsTrue(s1.IsNotEmpty);
            Assert.IsFalse(s1.IsEmpty);

            Assert.IsTrue(s1.Contains(arr1[0]));
        }


        [Test]
        public void Test_Constructor_Array_3()
        {
            long[] arr1 = new long[] {11111111,22222222,33333333};
            ImmTinySet<long> s1 = new ImmTinySet<long>(arr1);

            Assert.AreEqual(3, s1.Count);
            Assert.IsTrue(s1.IsNotEmpty);
            Assert.IsFalse(s1.IsEmpty);

            Assert.IsTrue(s1.Contains(arr1[0]));
            Assert.IsTrue(s1.Contains(arr1[1]));
            Assert.IsTrue(s1.Contains(arr1[2]));
        }


        [Test]
        public void Test_Plus_Basic_1()
        {
            ImmTinySet<long> s1 = new ImmTinySet<long>(1111,2222);
            ImmTinySet<long> s2 = new ImmTinySet<long>(3333,4444);

            RSet<long> s3 = s1 + s2;

            Assert.AreEqual(4, s3.Count);
            Assert.IsTrue(s3.Contains(1111));
            Assert.IsTrue(s3.Contains(2222));
            Assert.IsTrue(s3.Contains(3333));
            Assert.IsTrue(s3.Contains(4444));
        }


        [Test]
        public void Test_Plus_s1_morethan_s2()
        {
            ImmTinySet<long> s1 = new ImmTinySet<long>(1111,2222,3333,4444);
            ImmTinySet<long> s2 = new ImmTinySet<long>(2222,5555);

            RSet<long> s3 = s1 + s2;

            Assert.AreEqual(5, s3.Count);
            Assert.IsTrue(s3.Contains(1111));
            Assert.IsTrue(s3.Contains(2222));
            Assert.IsTrue(s3.Contains(3333));
            Assert.IsTrue(s3.Contains(4444));
            Assert.IsTrue(s3.Contains(5555));
        }


        [Test]
        public void Test_Plus_s2_morethan_s1()
        {
            ImmTinySet<long> s1 = new ImmTinySet<long>(1111,3333);
            ImmTinySet<long> s2 = new ImmTinySet<long>(2222,3333,4444,5555);

            RSet<long> s3 = s1 + s2;

            Assert.AreEqual(5, s3.Count);
            Assert.IsTrue(s3.Contains(1111));
            Assert.IsTrue(s3.Contains(2222));
            Assert.IsTrue(s3.Contains(3333));
            Assert.IsTrue(s3.Contains(4444));
            Assert.IsTrue(s3.Contains(5555));
        }
    }


}